import axios from "axios"
import { message } from "ant-design-vue";
const http = axios.create({
    timeout:10000,
    baseURL:"https://creationapi.shbwyz.com"
})

http.interceptors.request.use(config=>{
    let token = localStorage.getItem("token");
    if(token){
        config.headers.Authorization = 'Bearer '+token ;
    }
    return config
},err=>{
    return Promise.reject(err)
})

http.interceptors.response.use(data=>{
    // console.log(data)
    return data
},err=>{
    
//响应拦截 报错提示
    if(err.response.status === 400){
            message.error(err.response.data.msg)
        throw err
    }else if (err.response.status === 403) {
        message.warning("你的权限不太够阿，小熊dei")
        throw err
    }
    return Promise.reject(err)
})

export default http